#include<iostream>
#include<map>
#include<vector>
using namespace std;

#include"AVLTree.h"
void test1()
{
	//int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	AVLTree<int, int> t;

    
	for (auto e : a)
	{
		t.Insert(make_pair(e, e));
	}
	t.InOrder();
	t.Height();
	cout << t.IsBalance() << endl;
}
void test2()
{
	const int N = 1000000;
	vector<int> v;
	v.reserve(N);
	//srand(time(0));

	for (size_t i = 0; i < N; i++)
	{
		v.push_back(rand() + i);
		//cout << v.back() << endl;
	}

	size_t begin = clock();
	AVLTree<int, int> t;
	for (auto e : v)
	{
		if (e == 14604)
		{
			int x = 0;
		}

		t.Insert(make_pair(e, e));
		//cout << "Insert:" << e << "->" << t.IsBalance() << endl;
	}
	size_t end = clock();

	cout << "Insert时间：" << end - begin << endl;
	cout << "是否平衡：" << t.IsBalance() << endl;
	cout << "高度："; t.Height();
	cout << "个数："; t.Size();

}
int main()
{
	//test1();
	test2();
	return 0;
}
